package com.example.service.impl;

import com.example.mapper.NoteMapper;
import com.example.pojo.Note;
import com.example.pojo.PageBean;
import com.example.service.NoteService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDate;
import java.util.List;

@Service
public class NoteServiceimpl implements NoteService {

    @Autowired
    NoteMapper noteMapper;

    @Override
    public PageBean pagelist(Integer page, Integer pagesize,Integer type, LocalDate startTime, LocalDate endTime,String title) {
        List<Note> noteList=null;
        Integer count=noteMapper.Count();

        //分页查询的处理
        //起始索引
        Integer start=(page-1)*pagesize;
        noteList=noteMapper.pagelist(start,pagesize,type,startTime,endTime,title);

        PageBean pageBean=new PageBean(count,noteList);
        return pageBean;
    }

    @Override
    public void delete(List<Integer> ids) {
        noteMapper.delete(ids);
    }
}
